# !/usr/bin/python3
import warnings
import hashlib

warnings.filterwarnings(action='ignore', module='.*paramiko.*')

from cmd_line import Server

ip = "192.168.9.104"
line = Server(ip, 22, "muyi", "muyi@123")
line.connect()
# 使用channel发送交互指令
line.open_channel()
line.get_prompt(expect_symbol='$ ')
mes = line.channel_send_cmd('docker ps --filter name="mooe-core" --format "{{.Names}};{{.Image}}"', '$ ').split('\r\n')[
      1:3]
# line.open_ssh()
# mes = line.ssh_send_cmd('ls /mooe')
# mes = line.ssh_send_cmd('docker ps --filter name="mooe-core" --format "{{.Names}};{{.Image}}"')
# print(mes)
for i in range(2):
      mooe_core = mes[i].split(";")
      mooe_core_name = mooe_core[0]
      mooe_core_tag = mooe_core[1].split("/")[-1]
      mooe_core_tag_md5 = hashlib.md5(mooe_core_tag.encode('utf-8')).hexdigest()[:8]
      mooe_core = (mooe_core_name, f'{mooe_core_tag_md5}--> {mooe_core_tag}')
      print(mooe_core, type(mooe_core))
